/**
 * BaseServiceImpl.java
 * Product:BaseLayer
 * Version:1.0
 * Copyright 2009 by DNE
 * All Rights Reserved.
 */
package com.site.util.base.service;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.site.util.exception.ApplicationException;
import com.site.util.exception.SystemException;


/**
 * Service基类，处理一些公共事务，如异常统一处理
 */
public abstract  class BaseServiceImpl implements BaseService{
	protected Log log=LogFactory.getLog(this.getClass());
	
	/*
	 * (non-Javadoc)
	 * @see com.dne.framework.base.service.BaseService#execute(java.lang.Object, java.lang.String)
	 */
	public final Object execute(Object obj,String command) throws SystemException,ApplicationException{
		try{
			return doExecute(obj,command);
		}catch(SystemException e){
			e.printStackTrace();
			throw e;
		}catch (ApplicationException e) {
			throw e;
		}catch (Exception e) {
			throw new SystemException(e.getMessage(),e);
		}
	}
	
	/**
	 * 子类去实现此方法，根据不同command，调用不同的方法，实现不同的操作
	 * @param obj 该对象一般为业务数据对象po,特殊情况下可以传其它对象传值
	 * @param command 操作命令，在service实现类中通过command判断进行什么样的操作
	 * @return Object 可以返回所有对象
	 * @throws SystemException 系统异常
	 * @throws ApplicationException 应用异常
	 */
	public abstract Object doExecute(Object obj,String command) throws SystemException,ApplicationException;

}
